<?php
class MenugroupAction extends CommonAction {
	public function index(){
        $typeid=(int)$this->_get('typeid');
        $typeid=$typeid!=1?0:$typeid;
		$this->listmap="1 and typeid=".$typeid;
		$this->listorder="sort";
        parent::_list();
		$list=$this->list;
		$this->assign('list',$list);
		$this->display();
	}



	public function edit(){
		$pid_list=$this->dao->where(array('pid'=>0))->select();
		$category=D('Category');
		foreach($pid_list as $k=>$v){
			$pid_list[$k]['sub']=$category->getListToArray1($v['id']);
		}
		
		$this->assign('pid_list',$pid_list);
		parent::edit();
	}
	
	//重写更新方法,防止用户选择自己作为父分类
	public function update(){
		if($this->_post('pid')==$this->_post('id')){
			$this->error('您不能选择当前分类作为父类');
		}else{
			parent::update();
		}
	}
}

?>